from django.shortcuts import render
from django.views import View
from django.http import HttpResponse
from django.utils.decorators import method_decorator


def my_decorator(func1):

    def wrapper(request, *args, **kwargs):
        print('装饰器被调用了')
        print('本次请求的路径:%s' % request.path)
        return func1(request, *args, **kwargs)

    return wrapper

# @my_decorator
# def demo(request):
#     return HttpResponse('hello')

# @method_decorator(my_decorator, name='dispatch')
# @method_decorator(my_decorator, name='get')
class DemoView(View):
    """类视图"""

    # @method_decorator(my_decorator)
    # @my_decorator
    def get(self, request):
        return HttpResponse('get')

    def post(self, request):
        return HttpResponse('post')

    def put(self, request):
        return HttpResponse('put')

    def delete(self, request):
        return HttpResponse('delete')





